﻿using System;
using System.Collections.Generic;
using System.Text;
using SimpleQueueingSystem.Interfaces;
using System.Messaging;

namespace SimpleQueueingSytem.Client
{
    public class QueueingService
    {
        public static void QueueRequest(IRequest request, string destinationQueueName)
        {
            if (!MessageQueue.Exists(destinationQueueName))
                MessageQueue.Create(destinationQueueName);

            MessageQueue queue
                = new MessageQueue(destinationQueueName);

            queue.DefaultPropertiesToSend.Recoverable = true;
            queue.Formatter = new BinaryMessageFormatter();

            queue.Send(request, "Invoke Command");
            queue.Close();
        }
    }
}
